package com.tuozixuan.spring6.validation.method2;

import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validator;

@Service
public class MyService1 {

	@Autowired
	private Validator validator;

	public boolean validator(User user) {
		Set<ConstraintViolation<User>> sets = validator.validate(user);
		return sets.isEmpty();
	}
}
